#include<bits/stdc++.h>
#define endl '\n'
using namespace std;
vector<string>dat;
int main()
{
	string path,ttl,t,itn;
	ifstream fin;
	ofstream fout;
	int avl=0,mis=0,tot=0;
	cout<<"Please paste the material list *.csv file here(with .csv suffix):";
	getline(cin,path);
	try
	{
		fin.open(path);
		fin>>ttl;
		while(fin>>t)
			dat.push_back(t);
		fin.close();
		cout<<"Total:"<<dat.size()<<" item(s)."<<endl;
		for(int i=0;i<dat.size();i++)
		{
			string name[4],buf="";
			int cnt=0;
			for(auto c:dat[i])
			{
				if(c==',')
					name[cnt++]=buf,buf="";
				else
					buf+=c;
			}
			int mis=stoi(name[1]);
			int box=mis/1728;mis%=1728;
			int x64=mis/63;mis%=64;
			dat[i]+=format(",{0},{1},{2}",box,x64,mis);
		}
		ttl+=format(",\"Shulker Box(es)\",\"x64\",\"Single\"");
		fout.open(path);
		fout<<ttl<<endl;
		for(auto it:dat)
			fout<<it<<endl;
		fout.close();	
	}
	catch(const exception& e)
	{
		cerr << e.what() << '\n';
	}
	cout<<"Done!"<<endl;
	system("pause");
	return 0;
}